package com.youfang.sixthmedia.message;

import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.youfang.sixthmedia.controller.HeaderController;
import com.youfang.sixthmedia.message.model.DetailComment;
import com.youfang.sixthmedia.net.Response;

public class GetCommentResponse extends Response {

	private List<DetailComment> dataList = new LinkedList<DetailComment>();

	@Override
	protected void decodeBody(JSONObject bodyJSON) throws Exception {

		JSONArray arr = bodyJSON.getJSONArray("data");
		for (int i = 0; i < arr.length(); i++) {
			JSONObject o = arr.getJSONObject(i);
			DetailComment item = new DetailComment();

			item.userid = o.getInt("userid");
			item.houseid = o.getString("houseid");
			item.createtime = o.getLong("createtime")*1000;
			item.updatetime = o.getLong("updatetime")*1000;
			item.commentcontent = o.getString("commentcontent");
			item.username = o.getString("username");
			item.nickname = getString(o, "nickname");
			item.logo = o.getString("logo");

			item.logoBitmap = HeaderController.Cache.getFromCache(item);
			this.dataList.add(item);

		}

	}

	public List<DetailComment> getDataList() {
		return dataList;
	}

	public void setDataList(List<DetailComment> dataList) {
		this.dataList = dataList;
	}

}
